package com.ckzp.jfinal.system.util;

import com.ckzp.core.util.ClientUtil;
import com.ckzp.jfinal.system.model.SysIp;

/**
 * Created by 51594 on 2022/7/19.
 */
public class SysIpUtil {

    /**
     * @return
     */
    public static SysIpUtil n() {
        return new SysIpUtil();
    }

    /**
     * @param ip
     * @return
     */
    public SysIp getIpAddress(String ip) {
        SysIp sysip = SysIp.dao.findFirst("select * from sys_ip where ip=?", ip);
        if (sysip == null) {
//            ClientUtil.Address address = ClientUtil.getIpAddress(ip);
//            sysip = new SysIp();
//            if (address.isdata) {
//                sysip.set("ip", ip).set("global", address.getGlobal()).set("nation", address.getNation())
//                        .set("province", address.getProvince()).set("city", address.getCity()).set("isp", address.getIsp()).save();
//            } else {
//                sysip.set("ip", ip).set("global", "未知").set("nation", "未知")
//                        .set("province", "未知").set("isp", "未知")
//                        .set("city", "未知");
//            }
        }
        return sysip;
    }
}
